package com.woniuxy.credit_loans.staff_dong.service.impl;

import com.woniuxy.credit_loans.entity.Emp;
import com.woniuxy.credit_loans.mapper.EmpMapper;
import com.woniuxy.credit_loans.staff_dong.dto.EmpDto;
import com.woniuxy.credit_loans.staff_dong.service.EmpService;
import com.woniuxy.credit_loans.staff_dong.vo.EmpVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
    private EmpMapper empMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return empMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Emp record) {
        return empMapper.insert(record);
    }

    @Override
    public int insertSelective(Emp record) {
        return empMapper.insertSelective(record);
    }

    @Override
    public Emp selectByPrimaryKey(Long id) {
        return empMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Emp record) {
        return empMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Emp record) {
        return empMapper.updateByPrimaryKey(record);
    }

    @Override
    public Emp login(EmpDto empDto) {
        Emp emp = empMapper.selByAcc(empDto.getEmpAcc());
        if (emp != null && emp.getEmpType() == 1) {
            return empMapper.login(empDto);
        } else {
            return null;
        }
    }

    @Override
    public List<Emp> selAll() {
        return empMapper.selAll();
    }

    @Override
    public List<Emp> selAllProductLeaders() {
        return empMapper.selAllProductLeaders();
    }

    @Override
    public List<EmpVo> selectByLike(EmpDto empDto) {
        return empMapper.selectByLike(empDto);
    }
}
